package com.ruoyi.system.controller;

import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.controller.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
@RequestMapping("/api/map")
public class MapDataController {

    @Autowired
    private RestTemplate restTemplate;

    /**
     * 获取中国地图数据
     */
    @Anonymous
    @GetMapping("/china")
    public ResponseEntity<?> getChinaMapData() {
        String url = "https://geo.datav.aliyun.com/areas_v3/bound/100000_full.json";
        try {
            // 请求阿里云接口
            String response = restTemplate.getForObject(url, String.class);
            return ResponseEntity.ok().body(response);
        } catch (Exception e) {
            e.printStackTrace();
            return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("获取地图数据失败");
        }
    }
}
